;uNkNoWn`aWaY-system v
;Author: TheBouncer
;Url: http://www.tEaM-uNkNoWn.mypc.nu
;#HmongRaver scripters : TheBouncer
;E-mail : TheBouncer@tEaM-uNkNoWn.mypc.nu
;Channel: #HmongRaver Webnet server

on *:LOAD: { 
  set %logo 14~~ 15 uNkNoWn`aWaY-sYs 14 ~~  
  set %away not away 
  set %away.nick $$?="Enter Your Away Nick"
  set %idleaway on
  set %logger on 
  set %pager on 
  set %idletime 1200 
  set %timer.msg on 
  set %cwatch on
  set %preply on
  set %lreply on
  set %creply on
  set %msg.time 3600 
  set %pages 0 
  set %clogs 0 
  set %message 0 
  set %anickonoff on
  .timerautoaway 0 10 autoaway 
  echo -a 14 14,1~~~~ 0,1uNkNoWn`aWaY-system v bY: TheBouncer CopyRight  14,1~~~~ 0 you can get it on ==> #Hmong-Raver ~~
  echo -a 15 ~~ uNkNoWn`aWaY-system.mrc has been loaded ~~
}

on *:CONNECT: { .timerautoaway 0 10 autoaway }


on *:DISCONNECT: { .timerautoaway off }


alias away {
  if ($1 != $null) { setaway $1- | halt }
  else { setback }
}
alias setaway {
  set %oldnick $me
  if ($1 == $null) set %reason $$?="Enter Away Reason"
  else set %reason $1-
  .raw away [ %reason ]
  set %away away
  set %awaytime $ctime
  set %timestamp $time
  amsg [Away] [Reason: %reason $+ ] [Time Left: $time $+ ] [Logger: %logger $+ ] [Pager: %pager $+ ] %logo
  if (%anickonoff == on) {
  nick $me $+ %away.nick }
  .timerautoaway off
  if (%timer.msg == on) {
    .timeraway 0 %msg.time amsg [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] [Logger: %logger $+ ] [Pager: %pager $+ ] %logo

  }
}

alias setback { 
  nick %oldnick 
  .raw away 
  set %backtime $ctime 
  set %away not away 
  amsg [Back] [From: %reason $+ ] [Duration: $duration($calc(%backtime - %awaytime)) $+ ] %logo

  .timeraway off
  .timerautoaway 0 10 autoaway
  resetidle
  if (%pages > 0) {
    aecho -
    aecho [You Have Received %pages Page(s)]
    aecho [Type /readp To Read The Page(s)]
    aecho -
    set %pages 0
  }
  if (%message > 0) {
    aecho -
    aecho [You Have Received %message Message(s)]
    aecho [Type /open To Read The Message(s)]

    aecho -
    set %message 0
    if (%clogs > 0) {
      aecho -
      aecho [People who been talking with/about you]
      aecho [Type /readc to read the log(s)]
      aecho -
    set %clogs 0 }
  }
}

alias autoaway {
  if ($idle > %idletime) { 
    if (%away == not away) {
      if (%idleaway == on) {
        set %oldnick $me
        set %reason autoaway
        away [ %reason ]
        set %away Away
        set %awaytime $ctime
        set %timestamp $time
        amsg [Away] [Reason: %reason $+ ] [Time Left: $time $+ ] [Logger: %logger $+ ] [Pager: %pager $+ ] %logo

        if (%anickonoff == on) {
        nick $me $+ %away.nick }
        .timerautoaway off
        if (%timer.msg == on) {
          .timeraway 0 %msg.time amsg [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] [Logger: %logger $+ ] [Pager: %pager $+ ] %logo

        }
      }
    }
  }
}

alias status {
  if (%away == away) {
    aecho -
    aecho [away] 
    aecho [reason: %reason $+ ] 
    aecho [since: %timestamp $+ ] 
    aecho [autoaway: %idleaway $+ ]
    aecho [autoback: %autoback $+ ]
    aecho [logger: %logger $+ ] 
    aecho [pager: %pager $+ ]
    aecho [c.watch: %cwatch $+ ]
    aecho [idle time: $calc(%idletime / 60) min $+ ] 
    aecho [away nick: %anickonoff / %away.nick $+ ] 
    aecho [nick pass: %nick.pass $+ ] 
    aecho [timer msg: %timer.msg $+ ]
    aecho [message time: $calc(%msg.time / 60) min $+ ]
    aecho [auto ident: %aident $+ ] 
    aecho [pager reply: %preply $+ ]
    aecho [logger reply: %lreply $+ ]
    aecho [c.watch reply: %creply $+ ]
  aecho - }
  else {
    aecho -
    aecho [not away] 
    aecho [autoaway: %idleaway $+ ]
    aecho [autoback: %autoback $+ ]
    aecho [logger: %logger $+ ] 
    aecho [pager: %pager $+ ]
    aecho [c.watch: %cwatch $+ ]
    aecho [idle time: $calc(%idletime / 60) min $+ ] 
    aecho [away nick: %anickonoff / %away.nick $+ ] 
    aecho [nick pass: %nick.pass $+ ]
    aecho [timer msg: %timer.msg $+ ]
    aecho [message time: $calc(%msg.time / 60) min $+ ]
    aecho [auto ident: %aident $+ ] 
    aecho [pager reply: %preply $+ ]
    aecho [logger reply: %lreply $+ ]
    aecho [c.watch reply: %creply $+ ]
    aecho -
  }
}

alias Wisperaway {
  set %oldnick $me
  set %reason $$?="Please enter here your Away Reason Wisper-Away"
  away [ %reason ]
  set %away away
  set %awaytime $ctime
  set %timestamp $time
  aecho [Away] [Reason: %reason $+ ] [Time Left: $time $+ ] [Logger: %logger $+ ] [Pager: %pager $+ ]  %logo

  if (%anickonoff == on) {
  nick $me $+ %away.nick }
  .timerautoaway off
}

alias Wisperback {
  nick %oldnick 
  away 
  set %backtime $ctime 
  set %away not away 
  aecho [Back] [From: %reason $+ ] [Duration: $duration($calc(%backtime - %awaytime)) $+ ] %logo

  .timeraway off
  .timerautoaway 0 10 autoaway
  resetidle
  if (%pages > 0) {
    aecho -
    aecho [You have received %pages page(s)]
    aecho [Type /readp to read the page(s)]
    aecho -
    set %pages 0
  }
  if (%message > 0) {
    aecho -
    aecho [You have received %message message(s)]
    aecho [Type /open to read the message(s)]
    aecho -
    set %message 0
  }
  if (%clogs > 0) {
    aecho -
    aecho [People who been talking with/about you]
    aecho [Type /readc to read the log(s)]
    aecho -
    set %clogs 0 
  }
}

alias open {
  .play -e $mircdirlogs\logger.txt 10
  write -c $mircdirlogs\logger.txt
}

alias readp {
  .play -e $mircdirlogs\pager.txt 10
  write -c $mircdirlogs\pager.txt
}

alias readc {
  .play -e $mircdirlogs\cwatch.txt 10
  write -c $mircdirlogs\cwatch.txt
}

on 1:open:?:{
  if (%away == away) {
    close -m $nick
  }          
}

on 1:TEXT:*:?:{ 
  if (%away == away) {
    if (%logger == on) {
      inc %message
      if (%lreply == on) {
        notice $nick [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] - [Logged your message] %logo
      }
      write $mircdirlogs\logger.txt [Message by: $nick $+ ] [message: $1- $+ ] 
    } 
    if (%away == away) {
      if (%logger == off) {
        if (%lreply == on) {
          notice $nick [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] %logo

        }
      }
    }
  } 
}

ctcp *:page:*: {
  if (%away == away) {
    if (%pager == on) {
      inc %pages
      if (%preply == on) {
      notice $nick [Page received] [At: $time $+ ] }
      aecho -
      aecho [You have been paged by: $nick $+ ] on [ $+ $fulldate $+ ]
      aecho [Message] [ $+ $2- $+ ]
      aecho [end of page]
      aecho -
      write $mircdirlogs\pager.txt [paged by: $nick $+ ] [message: $2- $+ ] 
    }
  }
}

on *:TEXT:$(* $+ $me $+ *):#: {
  if (%away == away) {
    if (%cwatch == on) { 
      inc %clogs
      .notice $me $nick Said Your Nick In $chan $+ , Writing Log...
      write $mircdirlogs\cwatch.txt [message by: $nick $+ ] [message: $1- $+ ] 
      if (%creply == on) { notice $nick [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] %logo
      }
    }
    if (%away == away) {
      if (%cwatch == off) {
        if (%creply == on) {
          notice $nick [Away] [Reason: %reason $+ ] [Since: %timestamp $+ ] %logo
        }
      }
    }
  }
}

dialog setup { 
  title "uNkNoWn`aWaY-sYs bY: TheBouncer" 
  size -1 -1 280 189 
  tab "Away control",1, 10 10 259 140
  tab "Nick control",2,
  tab "Pager panel.",3, 
  button "close",5, 210 153 60 25, ok
  text "Away msg",6, 25 50 70 25,tab 1
  box "",7, 19 35 239 100
  check "Away message,",11, 25 50 90 25,right,tab 1 
  edit "",12, 173 50 30 20,tab 1
  text "Msg every",13, 119 55 50 20,tab 1
  text "Minute(s)",14, 208 55 50 20,tab 1
  check "Autoaway after",15, 25 75 90 25,right,tab 1
  edit "",16, 119 75 30 20,tab 1
  text "Minute(s) idle",17, 154 80 70 20,tab 1
  check "Away nick",19, 35 70 70 25,right,tab 2
  edit "",20, 137 70 120 20,tab 2
  text "your nick, will be nick+(afk)",50,45 100 150 15,disable, tab2 
  check "Pager",24, 25 50 90 25,right,tab 3
  check "Logger",25, 25 75 90 25,right,tab 3
  check "Channel watcher",26, 25 100 120 25,right,tab 3
  text "your nick +",27, 105 75 30 25,tab 2
  check "Reply",28, 129 50 90 25,right,tab 3
  check "Reply",29, 129 75 90 25,right,tab 3
  check "Reply",30, 129 100 90 25,right,tab 3
} 

on *:DIALOG:setup:sclick:*: {
  if ($did == 11) {
    if (%timer.msg == on) { set %timer.msg off | did -m setup 12 | halt }
    if (%timer.msg == off) { set %timer.msg on | did -n setup 12 | halt }
  }  
  if ($did == 15) {
    if (%idleaway == on) { set %idleaway off | did -m setup 16 | halt }
    if (%idleaway == off) { set %idleaway on | did -n setup 16 | halt }
  }

  if ($did == 19) {
    if (%anickonoff == on) { set %anickonoff off | did -m setup 20 | halt }
    if (%anickonoff == off) { set %anickonoff on | did -n setup 20 | halt }
  }

  if ($did == 24) {
    if (%pager == on) { set %pager off | halt }
    if (%pager == off) { set %pager on | halt }
  }
  if ($did == 25) {
    if (%logger == on) { set %logger off | halt }
    if (%logger == off) { set %logger on | halt }
  }
  if ($did == 26) {
    if (%cwatch == on) { set %cwatch off | halt }
    if (%cwatch == off) { set %cwatch on | halt }
  }
  if ($did == 28) {
    if (%preply == on) { set %preply off | halt }
    if (%preply == off) { set %preply on | halt }
  }
  if ($did == 29) {
    if (%lreply == on) { set %lreply off | halt }
    if (%lreply == off) { set %lreply on | halt }
  }
  if ($did == 30) {
    if (%creply == on) { set %creply off | halt }
    if (%creply == off) { set %creply on | halt }
  }
}

on *:DIALOG:setup:edit:*: {
  if ($did == 12) { 
    set %msg.time $did(12).text | set %msg.time $calc(%msg.time * 60)
  }
  if ($did == 16) { 
    set %idletime $did(16).text | set %idletime $calc(%idletime * 60)
  }
  if ($did == 20) { 
    set %away.nick $did(20).text
  }
  if ($did == 23) {
    set %nick.pass $did(23).text
  }
}

on *:DIALOG:setup:init:0: {
  if (%timer.msg == on) {
  did -c setup 11 }
  else { did -u setup 11 }
  if (%idleaway == on) {
  did -c setup 15 }
  else { did -u setup 15 }
  if (%anickonoff == on) {
  did -c setup 19 }
  else { did -u setup 19 }
  if (%pager == on) {
  did -c setup 24 }
  else { did -u setup 24 }
  if (%logger == on) {
  did -c setup 25 }
  else { did -u setup 25 }
  if (%cwatch == on) {
  did -c setup 26 }
  else { did -u setup 26 }
  if (%preply == on) {
  did -c setup 28 }
  else { did -u setup 28 }
  if (%lreply == on) {
  did -c setup 29 }
  else { did -u setup 29 }
  if (%creply == on) {
  did -c setup 30 }
  else { did -u setup 30 }
  if ($did(11).state == 0) {
  did -m setup 12 }
  else { did -a setup 12 $calc(%msg.time / 60) }    
  if ($did(15).state == 0) {
  did -m setup 16 }
  else { did -a setup 16 $calc(%idletime / 60) } 
  if ($did(19).state == 0) {
  did -m setup 20 }
  else { did -a setup 20 %away.nick }

}

raw 305:*: { haltdef }
raw 306:*: { haltdef }


alias aecho {
  echo -a $timestamp $1-
}
menu * { 
  uNkNoWn`aWaY-sYs
  .Top Stories:run http://www.tEaM-uNkNoWn.mypc.nu
  .$iif(!$server,$style(2)) $iif((%away == away),Set Back,Set Away):if (%away == away) setback | else setaway
  .$iif(!$server,$style(2)) $iif((%away == away),Wisper Back,Wisper Away):if (%away == away) Wisperback | else Wisperaway
  .-
  .controls: dialog -m setup setup 
}
